package com.sfpay.coreplatform.order.service.composite.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.sfpay.coreplatform.order.persistence.dao.IPayOrderDao;
import com.sfpay.coreplatform.order.persistence.dao.ITradeOrderDao;
import com.sfpay.coreplatform.order.service.composite.QueryOrderService;
import com.sfpay.coreplatform.order.valueobject.tmo.PayOrder;
import com.sfpay.coreplatform.order.valueobject.tmo.TradeOrder;

@Service
public class QueryOrderServiceImpl implements QueryOrderService {

	private final static Logger logger = LoggerFactory
			.getLogger(QueryOrderServiceImpl.class);
	@Resource
	private ITradeOrderDao tradeOrderDao;

	@Resource
	private IPayOrderDao payOrderDao;

	@Override
	public List<TradeOrder> queryPayTradeByOutTradeNo(Long platformMemberNo,
			String outTradeNo) {

		List<TradeOrder> trades = null;
		try {
			trades = tradeOrderDao.queryTraderOrderByBusinessNo(
					platformMemberNo, outTradeNo);

		} catch (Exception e) {
			logger.error("methode:queryPayTradeByOutTradeNo platformMemberNo:"
					+ platformMemberNo + ";outTradeNo " + outTradeNo
					+ " query exception ", e);
		}

		return trades;
	}

	public List<PayOrder> queryPayOrderByTradeNo(String tradeNo) {

		List<PayOrder> payOrders = null;
		try {
			payOrders = payOrderDao.queryPayOrderByTradeNo(tradeNo);
		} catch (Exception e) {
			logger.error("methode:queryPayTradeByOutTradeNo tradeNo:" + tradeNo
					+ " query exception ", e);
		}

		return payOrders;
	}
}
